﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Library.Utilities;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class RestaurantController
    {
        public int InsertRestaurant(RestaurantInfo info)
        {
            return SQL.InsertRestaurant(info.PartnerId, info.RestaurantTypeId, info.RestaurantFullName, info.RestaurantSortName, info.RestaurantEnglishName, info.SortDescription, info.DetailDescription, info.BuiltYear, info.ContinentId, info.NationalId, info.CityId, info.DistrictId, info.WardId, info.Address, info.RepresentName, info.RepresentPhone, info.RepresentHotline, info.RepresentFax, info.RepresentEmail, info.RepresentWebsite, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void UpdateRestaurant(RestaurantInfo info)
        {
            SQL.UpdateRestaurant(info.RestaurantId, info.PartnerId, info.RestaurantTypeId, info.RestaurantFullName, info.RestaurantSortName, info.RestaurantEnglishName, info.SortDescription, info.DetailDescription, info.BuiltYear, info.ContinentId, info.NationalId, info.CityId, info.DistrictId, info.WardId, info.Address, info.RepresentName, info.RepresentPhone, info.RepresentHotline, info.RepresentFax, info.RepresentEmail, info.RepresentWebsite, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void DeleteRestaurant(RestaurantInfo info)
        {
            DeleteRestaurant(info.RestaurantId);
        }
        public void DeleteRestaurant(int restaurantId)
        {
            SQL.DeleteRestaurant(restaurantId);
        }
        public RestaurantInfo GetRestaurant(int restaurantId)
        {
            return CBO.FillObject<RestaurantInfo>(SQL.GetRestaurant(restaurantId));
        }
        public List<RestaurantInfo> ListRestaurant()
        {
            return CBO.FillCollection<RestaurantInfo>(SQL.ListRestaurant());
        }
        public DataTable SelectRestaurant()
        {
            return CBO.ConvertToDataTable(ListRestaurant(), typeof(RestaurantInfo));
        }
        public List<RestaurantInfo> ListRestaurantByStatus(int status)
        {
            return ListRestaurant().Where(p=>p.Status == (int)Globals.DocumentStatus.Use).ToList();
        }
        public Dictionary<object, object> ListRestaurantLookup()
        {
            var pages = ListRestaurant();
            var dicpages = new Dictionary<object, object>();
            foreach (var info in pages)
                dicpages.Add(info.RestaurantId, info.RestaurantFullName);
            return dicpages;
        }
    }
}
